#include <iostream>
#include <map>
#include "..\utils.h"
#include <fstream>
using namespace std;
struct Node{
  double value;
  bool visited;
  map<Node*, double> p;
}nodes[1010];
int n, m, s;
void dfs(Node* node){
  if(node->visited){
    return ;
  }
  node->visited = true;
  for(pair<Node*, double> i : node->p){
    dfs(i.first);
    node->value += i.second / 100 * i.first->value;
  }
}
int main(){
  // 对于生成的k组数据，得出k组解，并写入out文件
  for(int k = 1; k <= 10; k++){

    // 初始化
    for(int i = 0; i < 1010; i++){
      nodes[i].value = 0;
      nodes[i].visited = false;
      nodes[i].p.clear();
    }

    // 文件流
    string inputFile = to_string(k) + ".in";
    string outputFile = to_string(k) + ".out";
    ifstream cin = createInputFStream(inputFile);
    ofstream cout = createOutputFStream(outputFile);

    cin >> n >> m >> s;
    for(int i = 1; i <= n; i++){
      cin >> nodes[i].value;
    }
    for(int i = 1; i <= m; i++){
      int x, y;
      double p;
      cin >> x >> y >> p;
      nodes[x].p[nodes + y] = p;
    }
    dfs(nodes + s);
    printf("%lf\n", nodes[s].value);

    char ans[100];
    sprintf(ans, "%.0lf", nodes[s].value);
    cout << ans << endl;
  }
}